import { defineStore } from 'pinia';

export const useMessageStore = defineStore('message', {
  state: () => ({
    messages: [
      { id: 1, message: '这是一条消息' },
      { id: 2, message: '这是一条官方消息' },
    ],
  }),
  actions: {
    addMessage(newMessage) {
      const newId = this.messages.length > 0 ? Math.max(...this.messages.map(m => m.id)) + 1 : 1;
      this.messages.push({ id: newId, message: newMessage });
    },
  },
});
